import { message, popupFormConfig, store } from '../message'

// bootstrapTable 响应事件方法合集
export const actionEvents = {
  'click .edit': function (e, value, row, index) {
    message.modal({
      type: 'options',
      title: '编辑',
      body: [
        popupFormConfig(row)
      ],
      showFooter: true,
      showConfirm: true,
      showCancel: true,
      cbConfirm: function(params) {
        var randomId = 100 + ~~(Math.random() * 100)
        message.close('modal')
        tableInstance.btTable.bootstrapTable('updateRow', {
          index: index,
          row: {
            id: randomId,
            name: 'Item ' + store.getById('d-name').attr('value'),
            price: '$' +store.getById('d-price').attr('value'),
          }
        })
      }
    })
  },
  'click .remove': function (e, value, row, index) {
    const ids = row.id        //需要字符串
    message.modal({
      type: 'normal',
      title: '是否删除此数据？',
      showFooter: true,
      showConfirm: true,
      showCancel: true,
      cbConfirm: function(params) {
        message.close('modal')
        tableInstance.btTable.bootstrapTable('remove', {
          field: 'id',
          values: ids
        })
      },
      bgClose: true
    })
  }
};